<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <!-- <button @click="showStore">仓库内容</button> -->
        <h1>{{counter}}</h1>
        <h1>{{totalPrice}}</h1>
        <button @click="box">点击了</button>
    </div>
</body>
<script src="./node_modules/vue/dist/vue.js"></script>
<script src="../vue-demos/node_modules/vuex/dist/vuex.js"></script>
<script>
    let store = new Vuex.Store({
        state: {
            counter: 0
        },
        grtters: {
            totalPrice: function (state) {
                return state.counter * 10;
            }
        },
        mutations: {
            increment: function (state) {
                state.counter += 1;
            }
        },
    })
    let vm = new Vue({
        store,
        computed: {
            totalPrice: function () { },
            ...Vuex.mapGetters(["totalPrice"]),
            ...Vuex.mapState(["counter"]),
        },
        el: "#app",
        methods: {
            box: function () {
                this.$store.commit("increment");
            }
        }
    })
</script>

</html>